﻿<UserControl x:Class="QuickMail.View.Controls.RulesControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <TreeView Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" x:Name="RulesTreeView"
                  SelectedItemChanged="TreeView_OnSelectedItemChanged"
                  MouseRightButtonDown="RulesTreeView_OnMouseRightButtonDown"
                  PreviewMouseLeftButtonDown="RulesTreeView_OnPreviewMouseLeftButtonDown"
                  FontSize="14">
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Childrens}">
                    <StackPanel Orientation="Horizontal" Margin="5, 0">
                        <Image Width="16" Height="16" Margin="0, 2, 3, 2" Source="{Binding ActionImage}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        <TextBlock Text="{Binding Title}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
            <TreeView.ContextMenu>
                <ContextMenu>
                    <MenuItem x:Name="AddMenuItem" Header="Add rule" Height="32"
                              Click="AddButton_OnClick">
                        <MenuItem.Icon>
                            <Image Source="../../Resources/plus2_math-32.png" Margin="5"/>
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem x:Name="DeleteMenuItem" Header="Delete rule" Height="32"
                              Click="DeleteButton_OnClick" IsEnabled="False">
                        <MenuItem.Icon>
                            <Image x:Name="DeleteMenuItemImage" Source="../../Resources/minus2_math-32.png"
                                   Opacity="0.5" Margin="5"/>
                        </MenuItem.Icon>
                    </MenuItem>

                    <MenuItem x:Name="PropertyMenuItem" Header="Properties of rule" Height="32"
                              Click="PropertyButton_OnClick" IsEnabled="False">
                        <MenuItem.Icon>
                            <Image x:Name="PropertyMenuItemImage" Source="../../Resources/support-32.png"
                                   Opacity="0.5" Margin="5"/>
                        </MenuItem.Icon>
                    </MenuItem>

                    <MenuItem x:Name="OpenFolderMenuItem" Header="Open folder" Height="32"
                              Click="OpenFolderMenuItem_OnClick" IsEnabled="False">
                        <MenuItem.Icon>
                            <Image x:Name="OpenFolderMenuItemImage" Source="../../Resources/opened_folder-32.png" 
                                   Opacity="0.5" Margin="5"/>
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </TreeView.ContextMenu>
        </TreeView>

        <Button Grid.Row="1" Grid.Column="0" x:Name="PropertyButton" Height="35"
                        Margin="5" Click="PropertyButton_OnClick" IsEnabled="False">
            <StackPanel Orientation="Horizontal">
                <Image x:Name="PropertyImage" Source="../../Resources/support-32.png" Margin="5, 0"/>
                <TextBlock x:Name="PropertyTextBlock" Text="PROPERTIES" FontSize="12" VerticalAlignment="Center"/>
            </StackPanel>
        </Button>

        <Button Grid.Row="1" Grid.Column="1" x:Name="DeleteButton" Width="35" Height="35" 
                        Margin="5" Click="DeleteButton_OnClick" IsEnabled="False">
            <Button.Content>
                <Image Source="../../Resources/minus2_math-32.png"/>
            </Button.Content>
        </Button>

        <Button Grid.Row="1" Grid.Column="2" x:Name="AddButton" Width="35" Height="35" 
                        Margin="5" Click="AddButton_OnClick">
            <Button.Content>
                <Image Source="../../Resources/plus2_math-32.png"/>
            </Button.Content>
        </Button>
    </Grid>
</UserControl>
